import com.alibaba.druid.pool.DruidDataSource;

public class DriudDemo {
    public static void main(String[] args) {
        //数据库的连接池
        DruidDataSource dataSource = new DruidDataSource();
        dataSource.setDriverClassName("com.mysql.jdbc.Driver");
        dataSource.setUrl("jdbc:mysql://localhost:3306/driud");
        dataSource.setUsername("root");
        dataSource.setPassword("hhpp");
        dataSource.setInitialSize(5);//初始化连接池大小
        dataSource.setMinIdle(5);//最小连接池数量
        dataSource.setMaxActive(10);//最大连接池数量
        dataSource.setMaxWait(60000);
        dataSource.setTimeBetweenEvictionRunsMillis(60000);
        dataSource.setMinEvictableIdleTimeMillis(60000);
        dataSource.setValidationQuery("SELECT 1");
        dataSource.setTestWhileIdle(true);
        dataSource.setTestOnBorrow(false);
        dataSource.setTestOnReturn(false);
        dataSource.setPoolPreparedStatements(true);

    }
}
